Hooks are special code used in software programming to "capture" information from the program on such things as performance data, RAS (Reliability, Availability, and Service) data, or execution tracing data. Once hooks are added to a program, output data resulting therefrom can be analyzed at a later time. The process of manually adding programming hooks can be error-prone and extremely time-consuming under the prior art. To add hooks to a program, the programmer may perform multiple steps. First, the programmer determines what code needs to be called by hooks. The programmer then edits the source code with a text editor, locating code that needs to be hooked sequentially. As the code for hooking is located, the programmer adds a hook code to the source file. Upon completion of adding a hook code, the programmer saves the updated source file, and the updated code is then compiled and linked.
In addition, the insertion of a hook may require the insertion of a hook exit as well. With the complexity of code that contains multiple exits points, it is very possible that a program will branch off to another portion of the program without coming to the hook exit. In addition, return statements in many languages can be complex and contain logic that may be skipped if a hook were placed in front of them. Thus, erroneous information may be produced. In addition, any time the programmer changes the code, it may be necessary to redo the hooks. It may also be necessary, in some cases, to rewrite the return statements, which may be time-consuming and frustrating. Thus, there is a need for a method for automating the addition of hooks to software.